<?php
namespace App\Repositories\Main;

use App\Models\Main\MsgSysReadModel;
use App\Repositories\BaseRepository;

class MsgSysReadRepository extends BaseRepository
{
    protected $repository;

    public function __construct()
    {
        $this->repository = new MsgSysReadModel();
    }

    public function getAdminIndex()
    {
        return $this->repository
            ->orderBy('id','desc')
            ->skip(0)
            ->take(10)
            ->get();
    }

    public function setAdd($data)
    {
        $data['created_at'] = time();
        return $this->repository->insertGetId($data);
    }

    public function setModifyRead($sysId,$uid)
    {
        $dataArr = array(
            'is_read' => 2,
            'updated_at' => time(),
        );
        return $this->repository
            ->where('msgSysId',$sysId)
            ->where('uid',$uid)
            ->update($dataArr);
    }

    public function getShowOne($sysId,$uid)
    {
        return $this->repository
            ->where('msgSysId',$sysId)
            ->where('uid',$uid)
            ->first();
    }
}